package com.financial.business.balance.service.impl;

import com.financial.business.balance.constants.FinancialBalanceEnumConstants;
import com.financial.business.balance.service.FinancialBalanceQueryService;
import com.financial.business.balance.service.gy.FinancialGYBalancePayQueryService;
import com.financial.business.balance.service.gy.FinancialGYBalanceRefundQueryService;
import com.financial.business.balance.service.yspay.FinancialBalanceYsPaymentQueryService;
import com.financial.business.balance.utils.JsonUtils;
import com.financial.business.balance.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //余额相关业务查询接口
 * @Date 2019/12/9 11:35
 */
@Service
public class FinancialBalanceQueryServiceImpl implements FinancialBalanceQueryService {
    public static final Logger logger = LoggerFactory.getLogger(FinancialBalanceQueryServiceImpl.class);

    @Autowired
    private FinancialGYBalancePayQueryService financialGYBalancePayQueryService;

    @Autowired
    private FinancialBalanceYsPaymentQueryService financialBalanceYsPaymentQueryService;

    @Autowired
    private FinancialGYBalanceRefundQueryService financialGYBalanceRefundQueryService;


    @Override
    public ApiResult query(String requestParam) {
        logger.info("FinancialBalanceQueryServiceImpl.query---接收余额查询参数json" + requestParam);
        /*银盛查询*/
        Map<String, Object> condMap = JsonUtils.jsonToMap(requestParam);
        String queryType = (String) condMap.get("query_type");
        logger.info("YsBusinessServiceImpl.query()----金融中心银盛基类，获查询付类型：" + queryType);
        ApiResult apiResult = ApiResult.failure(FinancialBalanceEnumConstants.ENUM_QUERYTYPE_ERROR);
        if (queryType.equalsIgnoreCase(FinancialBalanceEnumConstants.ENUM_QUERYTYPE_PAY)) {
            /*够样余额支付查询*/
            apiResult = financialGYBalancePayQueryService.payQuery(requestParam);
        } else if (queryType.equalsIgnoreCase(FinancialBalanceEnumConstants.ENUM_QUERYTYPE_PAYMENT)) {
            /*够样余额代付*/
            apiResult = financialBalanceYsPaymentQueryService.paymentQuery(requestParam);
        } else if (queryType.equalsIgnoreCase(FinancialBalanceEnumConstants.ENUM_QUERYTYPE_REFUND)) {
            /*够样余额退款*/
            apiResult = financialGYBalanceRefundQueryService.refundQuery(requestParam);
        } else {
            /*银盛其他查询*/
        }
        return apiResult;
    }
}
